<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php
require_once("classes/functions.php");
require_once("classes/db_functions.php");
$db = new db_functions();
/*
$kamid = intval(getFromInput("kampanja"));
$kampanje = $db->select1("SELECT kampanja_id, kampanja_naziv FROM kampanje ORDER BY kampanja_start_date DESC");
?>
<form action="kd.php" method="POST">
<select name="kampanja" id="kampanja">
<?php
foreach ($kampanje as $kam){
	$select = ($kam[0]==$kamid)?" selected":"";
	?>
	<option value="<?php echo $kam[0]; ?>"<?php echo $select; ?>><?php echo $kam[1]; ?></option>
	<?php
}
?>
</select>
<input type="submit" value="GO!" />
</form>
<?php

if ($kamid<1) {
	die();
}

$opstine = $db->getOne("SELECT value FROM listing_settings WHERE name='opstine' AND kampanja=$kamid LIMIT 1");

if ($opstine === null) {
	die("Nema definisanih opstina za zadatu kampanju. Pogledajte podešavanja listinga za odabranu kampanju.");
}*/


$delatnosti = $db->select1("SELECT delatnost_id, delatnost_ime FROM delatnosti ORDER BY delatnost_ime");
echo '
<table cellspacing="0" cellpadding="5" border="1">
	<tr>
		<td>#</td>
		<td>ID</td>
		<td>naziv</td>
		<td>komitenata</td>
	</tr>
';
foreach ($delatnosti as $k=>$del){
		
	$numKom = $db->select1("SELECT DISTINCT komdel_kom_id FROM komitenti_delatnosti WHERE komdel_del_id=".$del[0]);
	$numKom = count($numKom);
	
	
	echo "<tr><td>".($k+1).".</td><td>".$del[0]."</td><td>".$del[1]."</td><td>".$numKom."</td></tr>\n";
}
echo '</table>';
?>